Page({
  data: {
    rgb: 'rgb(0,0,0)',
    pick: false
  },
  toPick: function () {
    this.setData({
      pick: true
    })
  },
  toCopy: function () {
    wx.setClipboardData({
      data: 'https://github.com/MakerGYT/mini-color-picker'
    })
  },
  colorRGBtoHex(color) {
    var rgb = color.split(',');
    var r = parseInt(rgb[0].split('(')[1]);
    var g = parseInt(rgb[1]);
    var b = parseInt(rgb[2].split(')')[0]);
    var hex = "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
    return hex;
 },
  pickColor(e) {
    let rgb = e.detail.color;
    console.log("当前色值", rgb)
    this.setData({
      rgb
    })
    wx.setNavigationBarColor({
      frontColor: '#000000',
      backgroundColor: this.colorRGBtoHex(rgb),
      animation: {
        duration: 400,
        timingFunc: 'easeIn'
      }
    })
  }
})